$def with (auth_methods, error="")

$#
$# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for
$# more information about the licensing of this file.
$#

$var title: $:_("Welcome")

$# Start content

<div class="row justify-content-center">
    <div class="col-sm-4">
        <div class="card card-body bg-light">
            $if error:
                <div class="alert alert-danger" role="alert">
                    <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">$:_("Close")</span></button>
                    $:error
                </div>

            $if allow_registration:
                <form role="form" method="post">
                    <div class="form-group">
                        <label>$:_("Username")</label> <input type="text" class="form-control" name="login" placeholder="$:_('Username')" tabindex="1">
                    </div>
                    <div class="form-group">
                        <label>$:_("Password") </label> <input type="password" class="form-control" name="password" placeholder="$:_('Password')" tabindex="2">
                    </div>
                    <button type="submit" class="btn btn-primary btn-block" tabindex="3">$:_("Sign in")</button>
                </form>

            $ auth_meths = auth_methods.items()
            $ remaining = len(auth_meths)
            $ on_line = min(remaining, 4)

            $if remaining:
                $if allow_registration:
                    <hr/>
                <h5 class="center-block text-center">$:_("Sign in with")</h5>

            $ authid = 0
            $for id, auth_method in auth_meths:
                $if authid % on_line == 0:
                    <div class="row justify-content-center">

                <div class="col-md-$(int(12/on_line)) text-center">
                    <a href="$get_homepath()/auth/signin/$auth_method.get_id()">
                        $:auth_method.get_imlink()
                    </a>
                </div>

                $ remaining = remaining - 1
                $if authid % on_line == on_line-1:
                    </div>
                    $ on_line = min(remaining, 4)
                    $ authid = 0
                $else:
                    $ authid += 1
        </div>
    </div>
</div>
